package com.heima.search.controller;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.search.pojos.ApUserSearch;
import com.heima.search.service.HistorySearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 陈辉
 * @data 2024 16:22
 */
@RestController
@RequestMapping("/api/v1/history")
public class HistorySearchController {
    @Autowired
    private HistorySearchService historySearchService;

    /**
     * 加载用户的搜索历史记录
     *
     * @return
     */
    @PostMapping("load")
    public ResponseResult loadHistory(){
        return historySearchService.load();
    }

    /**
     * 删除用户搜索记录
     *
     * @param search
     * @return
     */
    @PostMapping("/del")
    public ResponseResult del(@RequestBody ApUserSearch search){
        return historySearchService.del(search);
    }
}
